<template>
  <div class="warp">
    <div class="login-container">
      <el-card style="max-width: 450px">
        <template #header>
          <div class="card-header">
            <span>抽奖管理后台</span>
          </div>
        </template>
        <div style="padding: 10px">
          <el-input v-model="state.info.account" placeholder="请输入账号">
            <template #prepend><el-icon>
                <UserFilled />
              </el-icon></template>
          </el-input>
          <el-input type="password" v-model="state.info.passWord" placeholder="请输入密码" style="margin-top: 20px;">
            <template #prepend><el-icon>
                <Lock />
              </el-icon></template>
          </el-input>
          <el-button type="primary" style="width: 100%;margin-top: 50px;" @click="login">登录</el-button>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useLoginApi } from "@/api/login";
import { Session } from "@/utils/storage";
import { reactive } from "vue";
import { useRouter } from "vue-router"
const router = useRouter()
const state = reactive({
  info: {
    account: '',
    passWord: '',
  }
});

const login = () => {
  useLoginApi(state.info).then(({ content }: any) => {
    Session.set("token", content)
    router.replace('/index')
  })
};

</script>
<style scoped lang="scss">
.warp {
  height: 100vh;
  background-color: azure;

  .login-container {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}

.card-header {
  font-weight: 900;
}
</style>
